<?php
if (isset($_POST["getMember"]))
{
	include("Library.php");
	$xml=new xmlLibrary();
$a=$xml->GetValueOfXpath($_POST['getMember'],'resource.xhtml');
echo json_encode($a);
    die;
}
if (isset($_POST["xpath2"]))
{
	include("Library.php");
	$xml=new xmlLibrary();
	$xpath=$_POST['xpath2'];
	if(substr($xpath,0,1)=='/')
		$xpath=substr($xpath,1);
	if(substr($xpath,strlen($xpath)-1)=='/')
		$xpath=substr($xpath,0,strlen($xpath)-1);
	$arr=split('/',$xpath);
	foreach($arr as $item)
	{
		if(substr($item,strlen($item)-1)!=']')
		{
			$item=$item.'[1]';
		}
		$content.=$item.'/';
	}
	$a=$xml->GetValueOfXpath($content,'resource.xhtml');
echo json_encode($a);
    die;
}
if(isset($_POST['getTitle']))
{
	$data=$_POST['getTitle'];
	{
		$data=preg_replace("/<.*?>\s*/","",$data);
		$data=preg_replace('/<\/.*?>\s*/',"",$data);
	}
	echo json_encode($data);
    die;
}
if(isset($_POST['getHead']))
{
	$data=$_POST['getHead'];
	preg_match('/<.*?>(?<content>.*)<\/.*?>/',$data,$result);
	$data= $result['content'];
	echo json_encode($data);
    die;
}
if(isset($_POST['getImage'])&&isset($_POST['URL']))
{
	include("Library.php");
	$image=GetNews::GetImage($_POST['getImage']);
	$linkimage=$image[0];
	if(!GetNews::str_start_with('http:\/\/',$linkimage)&&$linkimage!="")
	{
		$url=$_POST['URL'];	
		$url=GetNews::GetDomain($url);
		$linkimage=$url.$linkimage;
	}
	echo json_encode($linkimage);
    die;
}
?>
